<?php 
	require_once '../function.php';
	if (empty($_GET['id'])) {
		exit('<h1>参数错误</h1>');
	}
	$id = (int)$_GET['id'];
	// echo $id;
	if (!is_int($id)) {
		exit('<h1>请输入合法参数</h1>');
	}
	// $post_id = $_GET['id'];
	$post = xiu_fetch_db_one("select * from posts where id = {$id};");
	$user = xiu_fetch_db_one("select * from users where id = {$post['user_id']};");
	$category = xiu_fetch_db_all("select * from categories where user_id = {$user['id']} ;");
	


 ?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="/static/vendors/bootstrap4.6/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="/index/index.css">
</head>
<body>
	<div class="main">
		<?php include './inc/head-bar.php'; ?>
		<div class="container-fluid">
			<div class="row">
				<div class="col-md-2">
					<ul class="asid-category">
						<li class="category-hd">
							<h5>文章分类</h5>
						</li>
						<?php foreach ($category as $item): ?>
							<li><a href="javascript:;"><?php echo $item['name'] ?><span><?php echo xiu_fetch_db_one('select count(1) as num from posts where category_id ='.$item['id'])['num'] ?>篇</span></a></li>
						<?php endforeach ?>
					</ul>
				</div>
				<div class="col-md-9">
					<div class="post-content">
						<h1><?php echo $post['title']; ?></h1>
						<p>
							<span>发布时间：<?php echo $post['created']; ?></span>&nbsp;&nbsp;&nbsp;&nbsp;
							<span class="iconfont">&#xe663;</span>&nbsp;&nbsp;<?php echo $post['views']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
							<span class="iconfont">&#xe629;</span><?php echo $post['likes']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
							<span>作者：<?php echo $user['nickname']; ?></span>&nbsp;&nbsp;&nbsp;&nbsp;

						</p>

						<hr>
						<?php echo $post['html'] ?>
					</div>
				</div>
			</div>
			
		</div>
	</div>

	<script src="/static/vendors/jQuery.js"></script>

</body>
</html>

